export function downloadFile(res: any,fileName?: string){
    const { data, headers } = res
    if(!fileName){
        fileName = headers['content-disposition'].replace(/\w+;filename=(.*)/, '$1')
    }

    const blob = new Blob([data], {type: headers['content-type']})
    let dom = document.createElement('a') as any
    let url = window.URL.createObjectURL(blob)
    dom.href = url
    dom.download = decodeURI(fileName || 'null')
    dom.style.display = 'none'
    document.body.appendChild(dom)
    dom.click()
    dom.parentNode.removeChild(dom)
    window.URL.revokeObjectURL(url);
}